#include <iostream>
#include <vector>
using namespace std;

// 基类：形状
class CShape {
public:
    virtual void draw() const = 0; // 纯虚函数，表示抽象接口
    virtual ~CShape() {}           // 虚析构函数
};

// 派生类：圆形
class CCircle : public CShape {
public:
    void draw() const override {
        cout << "Drawing a Circle." << endl;
    }
};

// 派生类：矩形
class CRect : public CShape {
public:
    void draw() const override {
        cout << "Drawing a Rectangle." << endl;
    }
};

// 派生类：三角形
class CTriangle : public CShape {
public:
    void draw() const override {
        cout << "Drawing a Triangle." << endl;
    }
};

int main() {
    // 使用多态创建形状指针的集合
    vector<CShape*> shapes;
    shapes.push_back(new CCircle());
    shapes.push_back(new CRect());
    shapes.push_back(new CTriangle());

    // 遍历并绘制每种形状
    for (const auto& shape : shapes) {
        shape->draw();
    }

    // 释放内存
    for (const auto& shape : shapes) {
        delete shape;
    }

    return 0;
}